//
//  MonthRecordCell.swift
//  E-CycleForShop
//
//  Created by enghou on 17/3/8.
//  Copyright © 2017年 xyxorigation. All rights reserved.
//

import UIKit

class MonthRecordCell: UITableViewCell {

    
    //缺一个model
    var model : TurnOverModel? {
        didSet{
            if let mod = model!.dataSrc.first {
                if mod.time.characters.count > 7 {
                    let idx = mod.time.index(mod.time.startIndex, offsetBy: 7)
                    let time = mod.time.substring(to: idx);
                    let idx1 = time.index(time.startIndex, offsetBy: 4)
                    let idx2 = mod.time.index(time.endIndex, offsetBy: -2)
                    titleLbl.text = time.substring(to: idx1) + "年" + time.substring(from: idx2) + "月"
                } else {
                    titleLbl.text = mod.time
                }
            }
            table?.handleData(model: model!)
        }
    }
    var table : CellTableView?
    var titleLbl : UILabel = UILabel.init()
    var totalHeight : CGFloat = 0.0
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        titleLbl.textColor = UIColor.colorWithHexString(hex: "2c2c2c")
        titleLbl.font = UIFont.systemFont(ofSize: 28 * YXWidthScale)
        titleLbl.textAlignment = .left
        titleLbl.frame = CGRect.init(origin: CGPoint.init(x: 28 * YXWidthScale, y: 0), size: CGSize.init(width: YXDeviceWidth - 56 * YXWidthScale, height: 88 * YXHeightScale))
        self.contentView.addSubview(titleLbl)
        
        table = CellTableView.init(frame: CGRect.init(origin: CGPoint.init(x: 28 * YXWidthScale, y: 88 * YXHeightScale), size: CGSize.init(width: YXDeviceWidth - 56 * YXWidthScale, height: 0)))
        table?.layer.cornerRadius = YXButtonCorner
        self.contentView.addSubview(table!)
    }
    
    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
